import utils from '../utils'
import Furniture from '../furniture'
function getFrameSize(bounds, opts) {
  const aspectRatio = bounds.width() / bounds.height()
  let width = null
  if (opts.pixels) {
    width = Math.sqrt(+opts.pixels * aspectRatio)
  } else {
    width = +opts.width
  }
  const height = width / aspectRatio
  return [Math.round(width), Math.round(height)]
}
// @lyr dataset layer
function isFrameLayer(lyr) {
  return Furniture.getFurnitureLayerType(lyr) == 'frame'
}
function findFrameLayerInDataset(dataset) {
  return utils.find(dataset.layers, function(lyr) {
    return isFrameLayer(lyr)
  })
}
export default {
  getFrameSize,
  findFrameLayerInDataset,
}